/**
 * Copyright (c) 2009-2011, chunquedong(YangJiandong)
 * 
 * This file is part of ChunMap project
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
 * 
 * History:
 *     2010-05-05  Jed Young  Creation
 */
package chunmap.util;

/**
 * 我的断言
 * @author chunquedong
 * 
 */
public class MyAssert {
	public static void equals(Object obj, Object other) {
		if (!obj.equals(other)) {
			throw new AssertionEexception("not equals");
		}
	}

	public static void notNull(Object obj) {
		if (obj == null) {
			throw new AssertionEexception("null pointer");
		}
	}

	public static void notNull(Object ...objects) {
		for (Object obj : objects) {
			if (obj == null) {
				throw new AssertionEexception("null pointer");
			}
		}
	}

	public static void isTrue(boolean condition) {
		if (!condition) {
			throw new AssertionEexception("null pointer");
		}
	}

	public static void unreachableCode() {
		throw new AssertionEexception("unreachable code");
	}

	public static class AssertionEexception extends ChunMapRuntimeException {
		private static final long serialVersionUID = -650206381011080688L;

		public AssertionEexception(String message) {
			super(message);
		}
	}
}